<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="UTF-8">
		<title>红酒会 - 智能红酒管家</title>
		<link rel="shortcut icon" type="image/x-icon" href="${ctx}/favicon.ico" />
		<link type="text/css" rel="stylesheet" href="${ctx}/static/styles/bootstrap.min.css" />
	</head>
<body>
	
	<c:import url="/header"><c:param name="module">vintry</c:param></c:import>
	<c:import url="/vintry/menu"><c:param name="menu">5</c:param></c:import>
	<c:import url="/talk/right" />
	
	<div class="outWrap">
		<div class="spekBoxIn entde">
			<div style="min-height:670px;">
				<form id="form" action="${ctx}/vintry/taste/create" method="post" class="form-horizontal">
					<div class="control-group">
						<label class="control-label" for="chName">酒名（中文）</label>
						<div class="controls">
							<input type="text" id="chName" name="chName" class="input-xlarge"
								placeholder="中外文至少填写一项">
							<span id="error_chName" class="red"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="enName">酒名（外文）</label>
						<div class="controls">
							<input type="text" id="enName" name="enName" class="input-xlarge"
								placeholder="中外文至少填写一项">
							<span id="error_enName" class="red"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="vintage">年份</label>
						<div class="controls">
							<div class="input-prepend input-append">
				  				<input type="text" id="vintage" name="vintage" class="input-mini" placeholder="2000"
				  					value="${wine.vintage}">
				  				<span class="add-on">年</span>
							</div>
							<span id="error_vintage" class="red"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="rating">综合评价</label>
						<div class="controls">
							<span id="star"></span>
							<span id="hint"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="comment">品酒文</label>
						<div class="controls">
							<textarea id="comment" name="comment" rows="10" style="width:80%" placeholder="这酒怎么样？说两句吧！"></textarea>
							<div id="error_comment" class="red"></div>
						</div>
					</div>
					<div class="control-group">
				    	<div class="controls">
				    		<a href="${ctx}/vintry/tasting/list" class="btn">&nbsp;&nbsp;&nbsp;返&nbsp;&nbsp;&nbsp;回&nbsp;&nbsp;&nbsp;</a>
				      		<button type="submit" class="btn btn-info">&nbsp;&nbsp;&nbsp;提&nbsp;&nbsp;&nbsp;交&nbsp;&nbsp;&nbsp;</button>
				    	</div>
				  	</div>
					<input type="hidden" id="rating" name="rating" />
				</form>
			</div>
		</div>
	</div>
	
	<c:import url="/WEB-INF/views/footer.jsp" />

	<script type="text/javascript" src="${ctx}/static/scripts/jquery.validate.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/libs/raty/jquery.raty.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$('#star').raty({
				path	: '${ctx}/static/libs/raty/img',
				starHalf: 'star-half-big.png',
				starOff	: 'star-off-big.png',
				starOn	: 'star-on-big.png',
				hints	: ['差', '一般', '好', '非常好', '卓越'],
				target	: '#hint',
				targetKeep : true,
				click: function(score, evt) {
					$('#rating').val(score);
				}
			});
			$('#form').validate({
				rules: {
					chName: {
						maxlength: 50
					},
					enName: {
						maxlength: 50
					},
					vintage: {
						required: true,
						range: [1600, new Date().getFullYear()]
					},
					comment: {
						required: true
					}
				},
				messages: {
					chName: {
						maxlength: '中文名称不能超过50个字符'
					},
					enName: {
						maxlength: '英文名称不能超过50个字符'
					},
					vintage: {
						required: '请填写年份',
						range: '年份应该在{0}到{1}之间'
					},
					comment: {
						required: '请填写品酒文'
					}
				},
				errorElement: 'em',
				errorPlacement: function(error, element) {
					error.appendTo($("#error_" + element.attr("id")));
				},
				submitHandler: function(form) {
					if($('#chName').val()=='' && $('#enName').val()=='') {
						$('#error_chName').text('酒名（中文）或酒名（英文）必需填写一项');
						$('#error_enName').text('酒名（中文）或酒名（英文）必需填写一项');
					}else {
						form.submit();	
					}
				}
			});
		});
	</script>
</body>
</html>